package com.ruoyi.workbench.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.workbench.domain.WorkSystemManage;
import com.ruoyi.workbench.service.IWorkSystemManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 制度管理Controller
 * 
 * @author ruoyi
 * @date 2024-07-02
 */
@RestController
@RequestMapping("/jobAid/manage")
public class WorkSystemManageController extends BaseController
{
    @Autowired
    private IWorkSystemManageService workSystemManageService;

    /**
     * 新增制度管理
     */
    @PostMapping
    public AjaxResult add(@RequestBody WorkSystemManage workSystemManage)
    {
        return toAjax(workSystemManageService.insertWorkSystemManage(workSystemManage));
    }
    /**
     * 查询制度管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WorkSystemManage workSystemManage)
    {
        startPage();
        List<WorkSystemManage> list = workSystemManageService.selectWorkSystemManageList(workSystemManage);
        return getDataTable(list);
    }

    /**
     * 导出制度管理列表
     */
    @Log(title = "制度管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkSystemManage workSystemManage)
    {
        List<WorkSystemManage> list = workSystemManageService.selectWorkSystemManageList(workSystemManage);
        ExcelUtil<WorkSystemManage> util = new ExcelUtil<WorkSystemManage>(WorkSystemManage.class);
        util.exportExcel(response, list, "制度管理数据");
    }

    /**
     * 获取制度管理详细信息
     */
    @GetMapping(value = "/{sid}")
    public AjaxResult getInfo(@PathVariable("sid") Integer sid)
    {
        return success(workSystemManageService.selectWorkSystemManageBySid(sid));
    }


    /**
     * 修改制度管理
     */
    @Log(title = "制度管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkSystemManage workSystemManage)
    {
        return toAjax(workSystemManageService.updateWorkSystemManage(workSystemManage));
    }

    /**
     * 删除制度管理
     */
    @Log(title = "制度管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sids}")
    public AjaxResult remove(@PathVariable Integer[] sids)
    {
        return toAjax(workSystemManageService.deleteWorkSystemManageBySids(sids));
    }
}
